﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace SMSSender
{
    class Program
    {

        static private string url = "http://utf8.sms.webchinese.cn/?";// "http://sms.webchinese.cn/web_api/?";
         static private string strUid = "Uid=";
         static private string strKey = "&key=0fa32a7cb6e81bb43b01"; //这里*代表秘钥，由于从长有点麻烦，就不在窗口上输入了
       static  private string strMob = "&smsMob=";
        static private string strContent = "&smsText=";
        static void Main(string[] args)
        {

            if(true)// (txtUerName.Text.ToString().Trim() != "" && txtAttnNum.Text.ToString().Trim() != "" && txtContent.Text.ToString() != null)
                           {
                               url = url + strUid + "zhengfengbin" + strKey + strMob + "15810213368" + strContent + "验证码：8886";
                               string Result = GetHtmlFromUrl(url);

                //  MessageBox.Show(Result);

                Console.WriteLine(Result);


                Console.ReadKey();
                           }
        }

        public static string GetHtmlFromUrl(string url)
        {
            string strRet = null;
            if (url == null || url.Trim().ToString() == "")
            {
                return strRet;
            }
            string targeturl = url.Trim().ToString();
            try
            {
                HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(targeturl);
                hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
                hr.Method = "GET";
                hr.Timeout = 30 * 60 * 1000;
                WebResponse hs = hr.GetResponse();
                Stream sr = hs.GetResponseStream();
                StreamReader ser = new StreamReader(sr, Encoding.Default);
                strRet = ser.ReadToEnd();
            }
            catch (Exception ex)
            {
                strRet = null;
            }
            return strRet;
        }
    }
}
